/**
 * PageMarket
 * PushAction.java
 * com.android.pagemarket.io.protocol.in
 * 
 */
package com.android.pagemarket.io.protocol.in;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import com.android.pagemarket.io.protocol.out.PushResult;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-12-4
 * @see : 推送接口
 * @Copyright : copyrights reserved by personal 2007-2012
 **********************************************************/
public class PushAction extends HttpAction<PushResult>
{
    public String pushUrl;
    
    public PushAction(String pushUrl,String companyNum)
    {
        super("");
        this.pushUrl = pushUrl;
        addJsonParam("companyNum", companyNum);
    }
    
    public void setDateTime(String lastQutoDateTime,String lastLeaveTime)
    {
        addJsonParam("lastQutoDateTime", lastQutoDateTime);
        addJsonParam("lastLeaveTime", lastLeaveTime);
    }

    @Override
    public boolean isHttpGet()
    {
        return true;
    }

    @Override
    public String getAction()
    {
        String pushParam = "";
        try {
            pushParam = URLEncoder.encode(infoJsonObject.toString(), "UTF-8");
        } catch (UnsupportedEncodingException problem) 
        {
            throw new IllegalArgumentException(problem);
        }
        // 设置为 已取出
        infoJsonObject = null;
        return pushUrl + pushParam;
    }
    
    @Override
    protected PushResult parseJson(String response) throws Exception
    {
        PushResult one = new PushResult();
        one.parseResult(response);
        return one;
    }
}